package xhwl.insurance.adapter;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import xhwl.insurance.R;
import xhwl.insurance.http.bean.resp.UserGuideListResp;
import xhwl.insurance.http.bean.resp.VersionUpdateListResp;
import xhwl.insurance.ui.UserGudieDetailActivity;

/**
 * Created by Administrator on 2017/8/24.
 */

public class VersionUpdateAdapter extends BaseAdapter {
    Context context;
    List<VersionUpdateListResp> mlist;

    public VersionUpdateAdapter(Context context, ArrayList<VersionUpdateListResp> mlist) {
        this.context = context;
        this.mlist = mlist;
    }

    @Override
    public int getCount() {
        return mlist.size();
    }

    @Override
    public Object getItem(int position) {
        return mlist.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.user_guide_item, null);
            holder.update_version = (TextView) convertView.findViewById(R.id.update_version);
            holder.tv_update_detail = (TextView) convertView.findViewById(R.id.tv_update_detail);
            holder.time = (TextView) convertView.findViewById(R.id.time);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.update_version.setText(mlist.get(position).getCLIENT_VERSION() + "更新");
        holder.tv_update_detail.setText(mlist.get(position).getCLIENT_DESC());
        String mTime = mlist.get(position).getCREATE_DATE();
        String mData = mTime.substring(0, 10);
        String mYear=mData.substring(0,4);
        String mMonth=mData.substring(5,7);
        String mDataDetail=mData.substring(8,10);
        holder.time.setText(mYear+"年"+mMonth+"月"+mDataDetail+"日");
        return convertView;
    }

    class ViewHolder {
        TextView update_version, tv_update_detail, time;
    }
}
